package 力扣日常刷题.木22二月.第20天226;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 帅小伙
 * @date 2022/2/26
 * @description
 */
public class Demo163拆分成最多数目的正偶数之和 {


    public static void main(String[] args) {
        maximumEvenSplit(28);
    }
    public static List<Long> maximumEvenSplit(long finalSum) {
        ArrayList<Long> ans = new ArrayList<>();
        if(finalSum % 2 != 0) return ans;
        for (long i = 2; i <= finalSum ; i+=2) {
            ans.add(i);
            finalSum -= i;
        }
        Long a = ans.get(ans.size() - 1);
        ans.remove(ans.size() - 1);
        ans.add(a+finalSum);
        return ans;
    }

}
